<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>todoList</title>
    <style>
        .isFinshed {
            font-size: 1rem;
            font-weight: 800;
            color: red;
        }
    </style>
</head>
<body>
<div id="app">
    <div>{{message}}</div>
    <input type="text" v-model="message" @keyup.enter="itemsPush">
    <ul>
        <todo-items v-for="(item, index) in items" :key="index" :index="index" :content="item.label" @delete="handleDelete" :class="{isFinshed:item.isFinshed}"></todo-items>
    </ul>
</div>
</body>
<script src="https://cdn.bootcss.com/vue/2.4.2/vue.min.js"></script>
<script>
Vue.component('todo-items', {
    props: ['content', 'index'],
    template: '<li @click="handleClick">{{content}}</li>',
    methods: {
        handleClick: function () {
            this.$emit('delete', this.index);
        }
    },
});
var app = new Vue({
    el: '#app',
    data: {
        message: '',
        items: [

        ],
    },
    methods: {
        itemsPush: function () {
            if (this.message == '') {
                return false;
            } else {
                this.items.push({
                    label: this.message,
                    isFinshed: true
                });
            }
            this.message = '';
        },
        handleDelete: function (index) {
            this.items[index].isFinshed = !this.items[index].isFinshed;
        }
    },
});
</script>
</html>